#include "tests.h"
#include <stdio.h>


///////////////////////////////////////////////////////////////////////////////

// #define FILE_TRACE

#include "file_trace.h"

///////////////////////////////////////////////////////////////////////////////

void print_last_error()
{
	if (CU_registry_initialized() == CU_TRUE)
	{
	    CU_cleanup_registry();	
	}

	F_ERROR((CU_get_error_msg()));
}

CU_ErrorCode run_all_tests()
{
	CU_ErrorCode error = CUE_SUCCESS; 

    // initialize the CUnit test registry
    if (CU_initialize_registry() != CUE_SUCCESS)
	{
        print_last_error();
		return CUE_NOREGISTRY;	
	}

    // initialize each test suite
    add_test_suite_email();
	add_test_suite_read_from_file();
	add_test_task_scheduling();
	add_test_suite_date_time();
    add_test_suite_rss();

    // run all tests using the basic interface
	CU_basic_set_mode(CU_BRM_NORMAL);
    error = CU_basic_run_tests();

    // clean up registry
    CU_cleanup_registry();

    return error;
}
